<template>
  <div class="dashboard-container">
    <div class="dashboard-text" @click="">名字: {{ name }}</div>
    <p @click="setRoleFn">角色:{{ role }}</p>
  </div>
</template>

<script>
import { mapGetters,mapState,mapMutations,mapActions } from 'vuex'
import request from '@/utils/request'

export default {
  name: 'Dashboard',
  mounted(){
    request({url: '/system'}).then(res=>{
      console.log(res)
    })
  },
  methods:{
    ...mapMutations({
      setRole: 'user/SET_ROLE'
    }),
    ...mapActions({
      setRoleAsync:'user/setRoleAsync'
    }),
    setRoleFn(){
      this.setRole('一般同步')
      this.setRoleAsync('一般延时2s')
    }
  },
  computed: {
    ...mapGetters([
      'name'
    ]),
    ...mapState({
      role:state=>state.user.role
    })
  }
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
